/**
 *  @file Event.h
 */
#ifndef _THREADING_EVENT_H_
#define _THREADING_EVENT_H_

#include "../common/BaseObject.h"

namespace cppflib
{

namespace threading
{

/**
 *  A event class to notify other party about something.
 *  It is itself a semaphore internally.
 *
 *  This event is auto reset, i.e. if 'Wait' is successful, this 
 *  event goes back to non-signaled state automatically.
 */
class _DLLAPI Event : public BaseObject
{
private:
    BaseObject *pSem; ///< internal semaphore

public:
    Event(void);
    explicit Event(pcwstr_t name);
    virtual ~Event(void);

    void Set(void);
    void Wait(void);
    bool Wait(int timeout);
    void Close(void);
};

} // end of namespace threading


} // end of namespace cppflib


#endif
